<?
/*-- Project Introduce --*/


JCAT_Package::ImportClass('JCAT_UIGtkCtrlTree',JCAT::PACKAGE_UICTRLGTK) ;


/**
 *
 * @author		alee
 * @access		public
 */
class LstColumns extends JCAT_UIGtkCtrlTree
{

	
	/**
	 * what's this
	 * 
	 * @access	public
	 * @return	array
	 */
	public function LstColumns()
	{
		$this->JCAT_UIGtkCtrlTree('LstColumns',JCAT_Language::Sentence('列设定'),'LstColumns') ;
	}
	
	public function CreateModel()
	{
		return new GtkTreeStore(
				Gtk::TYPE_STRING
				, Gtk::TYPE_STRING
				, Gtk::TYPE_STRING
				, Gtk::TYPE_BOOLEAN
				, Gtk::TYPE_STRING
				, Gtk::TYPE_BOOLEAN
				, Gtk::TYPE_LONG
		) ;
	}
	
	/**
	 * 初始化  GtkTreeView 的列
	 * 
	 * @access	public
	 * @return	void
	 */
	public function InitializeColumns()
	{
		// 取得视图
		$wndTreeView = $this->GetMainWidget() ;
		JCAT_ASSERT::ASSERT_INSTANCE($wndTreeView,'GtkTreeView',
					JCAT_Language::SentenceEx('UI控件“%”的主窗体尚未创建，在正常情况下  InitializeColumns()不应该被直接调用，UI控件的主窗体在创建之时，会自动调用此方法。','JCAT',null,$this->GetName())) ;

		// 设置列		
		$aRenderer = new GtkCellRendererText() ;
		$aRenderer->set_property('editable',true) ;
		$aRenderer->connect('edited',array($this,'OnTextEdit'),self::CLM_HEAD_NAME) ;
		$aColumn = new GtkTreeViewColumn(JCAT_Language::Sentence('列头名称'),$aRenderer,'text',self::CLM_HEAD_NAME) ;
		$wndTreeView->append_column($aColumn) ;
		
		$aRenderer = new GtkCellRendererCombo() ;
		$aModelClm = new GtkTreeStore(Gtk::TYPE_STRING) ;
		$aModelClm->append(null,array('Gtk::TYPE_NONE')) ;
		$aModelClm->append(null,array('Gtk::TYPE_BOOLEAN')) ;
		$aModelClm->append(null,array('Gtk::TYPE_STRING')) ;
		$aModelClm->append(null,array('Gtk::TYPE_LONG')) ;
		$aModelClm->append(null,array('Gtk::TYPE_DOUBLE')) ;
		$aModelClm->append(null,array('Gtk::TYPE_OBJECT')) ;
		$aRenderer->set_property('model',$aModelClm) ; 
		$aRenderer->set_property('text-column', 0); 
		$aRenderer->set_property('editable', true);
		$aRenderer->set_property('has-entry', false);
		$aRenderer->connect('edited',array($this,'OnTextEdit'),self::CLM_MODEL_TYPE) ;
		$aColumn = new GtkTreeViewColumn(JCAT_Language::Sentence('模型类别'),$aRenderer,'text',self::CLM_MODEL_TYPE) ;
		$wndTreeView->append_column($aColumn) ;

		$aRenderer = new GtkCellRendererCombo() ;
		$aModelClm = new GtkTreeStore(Gtk::TYPE_STRING) ;
		$aModelClm->append(null,array('Text')) ;
		$aModelClm->append(null,array('Radio')) ;
		$aModelClm->append(null,array('Checkbox')) ;
		$aModelClm->append(null,array('Combo')) ;
		$aModelClm->append(null,array('ComboEntry')) ;
		$aModelClm->append(null,array('ProgressBar')) ;
		$aModelClm->append(null,array('Image')) ;
		$aModelClm->append(null,array('Hide')) ;
		$aRenderer->set_property('model',$aModelClm) ;
		$aRenderer->set_property('text-column', 0); 
		$aRenderer->set_property('has-entry',false) ;
		$aRenderer->set_property('editable',true) ;
		$aRenderer->connect('edited',array($this,'OnTextEdit'),self::CLM_VIEW_TYPE) ;
		$aColumn = new GtkTreeViewColumn(JCAT_Language::Sentence('视图类别'),$aRenderer,'text',self::CLM_VIEW_TYPE) ;
		$wndTreeView->append_column($aColumn) ;
		
		$aRenderer = new GtkCellRendererToggle() ;
		$aRenderer->set_property('activatable',true) ;
		$aRenderer->connect('toggled',array($this,'OnActiveToggled'),self::CLM_EDITABLE) ;
		$aColumn = new GtkTreeViewColumn(JCAT_Language::Sentence('可编辑'),$aRenderer,'active',self::CLM_EDITABLE) ;
		$wndTreeView->append_column($aColumn) ;
		
		$aRenderer = new GtkCellRendererText() ;
		$aRenderer->set_property('editable',true) ;
		$aRenderer->connect('edited',array($this,'OnTextEdit'),self::CLM_CONST_NAME) ;
		$aColumn = new GtkTreeViewColumn(JCAT_Language::Sentence('定义常量'),$aRenderer,'text',self::CLM_CONST_NAME) ;
		$wndTreeView->append_column($aColumn) ;
		
		$aRenderer = new GtkCellRendererToggle() ;
		$aRenderer->set_property('activatable',true) ;
		$aRenderer->connect('toggled',array($this,'OnActiveToggled'),self::CLM_SHOW) ;
		$aColumn = new GtkTreeViewColumn(JCAT_Language::Sentence('可见'),$aRenderer,'active',self::CLM_SHOW) ;
		$wndTreeView->append_column($aColumn) ;
		
		$aRenderer = new GtkCellRendererText() ;
		$aRenderer->set_property('editable',true) ;
		$aRenderer->connect('edited',array($this,'OnTextEdit'),self::CLM_WIDTH) ;
		$aColumn = new GtkTreeViewColumn(JCAT_Language::Sentence('固定宽度(像素)'),$aRenderer,'text',self::CLM_WIDTH) ;
		$wndTreeView->append_column($aColumn) ;
	}


	const CLM_HEAD_NAME = 0 ;
	const CLM_MODEL_TYPE = 1 ;
	const CLM_VIEW_TYPE = 2 ;
	const CLM_EDITABLE = 3 ;
	const CLM_CONST_NAME = 4 ;
	const CLM_SHOW = 5 ;
	const CLM_WIDTH = 6 ;

	// 属性 ///////////////////////////////////////////////////////////////////////////////


}

?>